package superAdmin;

import org.junit.jupiter.api.Assertions;
import org.openqa.selenium.By;
import org.openqa.selenium.WebDriver;
import org.openqa.selenium.chrome.ChromeDriver;

import java.util.concurrent.TimeUnit;

import static java.lang.Thread.sleep;

public class Test {
    @org.junit.jupiter.api.Test
    void test() throws InterruptedException {
        WebDriver webDriver = new ChromeDriver();
        //获取登录页
        webDriver.get("http://192.168.63.227:10001/digitrain/login/doLogout");
        webDriver.manage().window().maximize();
        webDriver.manage().timeouts().implicitlyWait(3, TimeUnit.DAYS);
        //输入账号密码
        webDriver.findElement(By.cssSelector("#login > div.logIn-inner > div.right-con.fr > div > div.login-form > form > div:nth-child(1) > div > div > input"))
                .sendKeys("superadmin");
        webDriver.findElement(By.cssSelector("#login > div.logIn-inner > div.right-con.fr > div > div.login-form > form > div:nth-child(2) > div > div > input"))
                .sendKeys("123");
        //点击登录
        webDriver.findElement(By.cssSelector("#login > div.logIn-inner > div.right-con.fr > div > div.login-form > form > div:nth-child(3) > div > button")).click();
        webDriver.manage().window().maximize();
        sleep(3000);

        String curUrl = webDriver.getCurrentUrl();
        Assertions.assertEquals("http://192.168.63.227:10001/digitrain/login/toIndex",curUrl);
        sleep(3000);
        webDriver.findElement(By.cssSelector("#schoolBox > div.tit > div:nth-child(2) > button:nth-child(2) > span")).click();
    }
}
